//
// Created by sjjmw on 3/24/2022.
//

//应该使用dfs

#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"
#include "map"
#include "list"
struct Sol{

void dfs(int begin,int famasum){

}
    std::vector<int> nums;
    void handle(
//            int n,int b
            ){
        int a,b;std::cin>>a>>b;
        int front_i=0,end_i=a-1;
        int took_cnt=0;
        int ans=1;
        nums.resize(a);
        for(int i=0;i<a;i++){
            std::cin>>nums[i];
        }
        if(a==1){
            if(nums[0]<0){
                printf("%d\n",nums[0]);
                return;
            }
        }
        std::sort(nums.begin(),nums.end());
        while (took_cnt<b){
            //刚好剩2两个时，如果只剩一个正数，那么只能选两个负数
            int fmul=0;
            bool only_two_minus=false;
            if(b-took_cnt==2){
                int zcnt=0;
                for(int i=front_i;i<=end_i;i++){
                    if(nums[i]>0){
                        zcnt++;
                    }
                }
                if(zcnt==1){
                    only_two_minus= true;
                }
            }
            if(b-took_cnt>=2//剩余2
                &&nums[front_i]<0&&nums[front_i+1]<0){
                fmul=nums[front_i]*nums[front_i+1];
            }
            int fend=0;
            if(nums[end_i]>0){
                fend=nums[end_i];
            }

            if(only_two_minus){
                took_cnt+=2;
                front_i+=2;
                ans*=fmul;
            }
            else if(fmul>fend){
                took_cnt+=2;
                front_i+=2;
                ans*=fmul;
            }else{
                took_cnt+=1;
                end_i--;
                ans*=fend;
            }
        }
        printf("%d\n",ans);
    }
};
int main(){
    int a,b,c;
//    float a,b,c,d;
    int e;
    while(std::cin>>a){
        for(int i=0;i<a;i++){
            Sol().handle();
        }
//        Sol().handle(a,b);
    }

    return 0;
}